package com.bzkj.basicinfo.mapper;

import com.bzkj.basicinfo.domain.ncc.StoUnit;
import com.bzkj.basicinfo.domain.wms.vo.ExportReportReceivingVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.HashMap;
import java.util.List;

/**
 * @Author: Admin
 * @Description: 货位数据访问层接口
 * 负责对货位相关数据的 CRUD 操作
 */
@Mapper
public interface StoUnitMapper
{

    /**
     * 新增货位
     *
     * @param stoUnit 要新增的货位对象
     * @return 受影响的记录数
     */
    int insertStoUnit(StoUnit stoUnit);

    /**
     * 批量插入
     * @param list
     * @return
     */
    int batchInsertStoUnit(List<StoUnit> list);

    /**
     * 更新货位
     *
     * @param stoUnit 要更新的货位对象
     * @return 受影响的记录数
     */
    int updateStoUnit(StoUnit stoUnit);

    /**
     * 根据 ID 查询货位
     *
     * @param stoUnitId 货位的唯一标识符
     * @return 查询到的货位对象
     */
    StoUnit selectStoUnitById(String stoUnitId);

    /**
     * 根据库区 ID 查询货位列表
     *
     * @param stoAreaId 库区的唯一标识符
     * @return 与该库区关联的货位列表
     */
    List<StoUnit> selectStoUnitsByAreaId(String stoAreaId);

    /**
     * 查询所有货位
     *
     * @return 所有货位的列表
     */
    List<StoUnit> selectAllStoUnits();

    /**
     * 删除货位
     *
     * @param stoUnitId 要删除的货位的唯一标识符
     * @return 受影响的记录数
     */
    int deleteStoUnit(String stoUnitId);


    StoUnit selectByStoUnitCode(String stoUnitCode);

    // 检查货位是否被使用
    boolean countUsageByStoUnitId(String stoUnitId);

    List<HashMap<String, Object>> queryStoUnit(@Param("sto_area_code") String sto_area_code, @Param("sto_unit_code") String sto_unit_code);

    List<HashMap<String, Object>> queryGoods(@Param("name") String name, @Param("materialspec") String materialspec, @Param("vbatchcode") String vbatchcode, @Param("pkMaterial") String pkMaterial);

    Long queryBigNumber();

    List<StoUnit> findStoUnitByStoAreaCodeAndStounitCode(@Param("stoAreaId") String stoAreaId);

    List<HashMap<String, Object>> queryStoUnitInfo(@Param("stoAreaCode") String stoAreaCode, @Param("stoUnitCode") String stoUnitCode);

    /**
     * 根据 ID 查询货位
     *
     * @return 查询到的货位对象
     */
    List<StoUnit> selectStoCode(@Param("stoUnitCode")String stoUnitCode,@Param("stoId")String stoId,@Param("stoAreaId")String stoAreaId);
    StoUnit selectUnitGubFlag(@Param("stoUnitCode")String stoUnitCode,@Param("stoId")String stoId);

    List<StoUnit> selectAllStoUnitCode(@Param("stoId") String stoId, @Param("stoAreaId") String stoAreaId);

    /**
     * 货位统计报表
     * @param wareHouseID
     * @param wareHouseValue
     * @param wareHouseTypeID
     * @param wareHouseTypeIDValue
     * @param unitTypeID
     * @param unitTypeIDValue
     * @param sType
     * @return
     */
    List<HashMap<String, Object>> wmsReportUnitStatistic(@Param("wareHouseID") String wareHouseID, @Param("wareHouseValue") String wareHouseValue,
                                                         @Param("wareHouseTypeID") String wareHouseTypeID, @Param("wareHouseTypeIDValue") String wareHouseTypeIDValue,
                                                         @Param("unitTypeID") String unitTypeID, @Param("unitTypeIDValue") String unitTypeIDValue,
                                                         @Param("sType") String sType);

    /**
     * 基础报表
     * @param skuID
     * @param skuClassID
     * @param wareHouseID
     * @param openBatchNo
     * @param batchNo
     * @param batchNoValue
     * @param beginDate
     * @param endDate
     * @param turnoverRateMinVal
     * @param turnoverRateMaxVal
     * @param turnoverDay
     * @param turnoverDayValue
     * @param skuRateMinVal
     * @param skuRateMaxVal
     * @return
     */
    List<HashMap<String, Object>> wmsReportBasicStatistic(@Param("skuID") String skuID, @Param("skuClassID") String skuClassID,
                                                          @Param("wareHouseID") String wareHouseID, @Param("openBatchNo") String openBatchNo,
                                                          @Param("batchNo") String batchNo, @Param("batchNoValue") String batchNoValue,
                                                          @Param("beginDate") String beginDate, @Param("endDate") String endDate,
                                                          @Param("turnoverRateMinVal") String turnoverRateMinVal, @Param("turnoverRateMaxVal") String turnoverRateMaxVal,
                                                          @Param("turnoverDay") String turnoverDay, @Param("turnoverDayValue") String turnoverDayValue,
                                                          @Param("skuRateMinVal") String skuRateMinVal, @Param("skuRateMaxVal") String skuRateMaxVal);

    /**
     * 呆滞天数
     * @param skuID
     * @param skuClassID
     * @param wareHouseID
     * @param batchNo
     * @param batchNoValue
     * @param sluggishBegin
     * @param sluggishEnd
     * @return
     */
    List<HashMap<String, Object>> wmsReportSluggishStatistic(@Param("skuID") String skuID, @Param("skuClassID") String skuClassID,
                                                             @Param("wareHouseID") String wareHouseID, @Param("batchNo") String batchNo,
                                                             @Param("batchNoValue") String batchNoValue, @Param("sluggishBegin") String sluggishBegin,
                                                             @Param("sluggishEnd") String sluggishEnd);

    /**
     * 不合格品
     * @param skuID
     * @param batchNo
     * @param batchNoValue
     * @return
     */
    List<HashMap<String, Object>> wmsReportUnqualifiedStatistic(@Param("skuClassId")String  skuClassId,@Param("skuID") String skuID, @Param("batchNo") String batchNo,
                                                                @Param("batchNoValue") String batchNoValue);

    /**
     * 产品发运记录（成品）报表
     * @param skuID
     * @param wareHouseID
     * @param shippingMethod
     * @param customerID
     * @param vbillsCode
     * @param batchNo
     * @param batchNoValue
     * @param wareHouseOutBills
     * @param beginDate
     * @param endDate
     * @return
     */
    List<HashMap<String, Object>> wmsReportDeliveryStatistic(@Param("skuID") String skuID, @Param("wareHouseID") String wareHouseID, @Param("shippingMethod") String shippingMethod,
                                                             @Param("customerID") String customerID, @Param("vbillsCode") String vbillsCode, @Param("batchNo") String batchNo,
                                                             @Param("batchNoValue") String batchNoValue, @Param("wareHouseOutBills") String wareHouseOutBills,
                                                             @Param("beginDate") String beginDate, @Param("endDate") String endDate);

    List<HashMap<String, Object>> wmsReportReceivingStatistic(@Param("skuClassID")String skuClassID,@Param("receivingDay") String receivingDay, @Param("releaseDay") String releaseDay,
                                                              @Param("stateID") String stateID, @Param("skuID") String skuID,
                                                              @Param("senderID") String senderID, @Param("manufacturerID") String manufacturerID,
                                                              @Param("batchNo") String batchNo, @Param("batchNoValue") String batchNoValue);

    List<ExportReportReceivingVo> exportWmsReportReceivingStatistic(@Param("skuClassID")String skuClassID,@Param("receivingDay") String receivingDay, @Param("releaseDay") String releaseDay,
                                                                    @Param("stateID") String stateID, @Param("skuID") String skuID,
                                                                    @Param("senderID") String senderID, @Param("manufacturerID") String manufacturerID,
                                                                    @Param("batchNo") String batchNo, @Param("batchNoValue") String batchNoValue);
    /**
     * 已盘点库房信息
     *
     * @param inventoryID
     * @param warehouseId
     * @return
     */
    List<HashMap<String, Object>> wmsInventoryCountReport(@Param("inventoryID") String inventoryID, @Param("warehouseId") String warehouseId);

    /**
     * 未盘点库房商品信息
     *
     * @param inventoryID
     * @param warehouseId
     * @return
     */
    List<HashMap<String, Object>> wmsNoCountReport(@Param("inventoryID") String inventoryID, @Param("warehouseId") String warehouseId);


}
